define(
   [
      'dojo/_base/declare',
      'dojo/_base/lang',
      'dijit/Dialog'
   ],
   function(declare, lang, Dialog)
   {
      return declare([Dialog], 
      {
         destroyOnClose: true,

         //Force dijit to not add overflow:hidden to their dialogs.
         _checkIfSingleChild: function () { return false; },
         hide: function(doConfirm)
         {
            if(this._hiding)
               return null;
            if(!this.alertHide || !doConfirm || confirm("You have unsaved changes! Are you sure you want to close?"))
            {
               this._hiding = true;
               return this.inherited(arguments);
            }

            return null;
         },
         onHide: function()
         {
            if(!this.destroyOnClose)
               return;

            setTimeout(lang.hitch(this, this.destroyRecursive), 50);
         }
      });
   }
);
